#pragma once

#include <string>

class ScopedTrace;

class Trace {
public:
    static void SetTraceFilename(const std::string &filename);
    static void DisableTrace();
    static void Start(const std::string &proc);
    static void Finish();
    static void Count(const std::string &key, int val);
};

class ScopedTrace {
public:
    ScopedTrace(const std::string &proc)
    {
        Trace::Start(proc);
    }

    ~ScopedTrace()
    {
        Finish();
    }

    void Finish()
    {
        if (isFinished == false) {
            isFinished = true;
            Trace::Finish();
        }
    }

private:
    bool isFinished = false;
};
